<?php

use App\Http\Controllers\Workflow\internal\SupplierTenderController;
use App\Http\Controllers\Workflow\WorkflowTemplateController;
use App\Http\Middleware\InternalApiAuth;
use App\Http\Middleware\OpenShop\FeishuWebAuth;
use App\Http\Middleware\OpenShop\UserPermissionAuth;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Workflow\WorkflowV2TemplateController;

// 其他
Route::prefix('common')->group(function () {

    // 所有枚举类型
    Route::get('enums', [WorkflowTemplateController::class, 'enums']);
    Route::get('enumsV2', [WorkflowV2TemplateController::class, 'enums']);
});

// 工作流模板
Route::prefix('template')->middleware([FeishuWebAuth::class, UserPermissionAuth::class])->group(function () {
    Route::post('/', [WorkflowTemplateController::class, 'add']);
    Route::put('/', [WorkflowTemplateController::class, 'edit']);
    Route::get('/{id}', [WorkflowTemplateController::class, 'detail']);
    Route::get('/', [WorkflowTemplateController::class, 'index']);
    Route::delete('/{id}', [WorkflowTemplateController::class, 'delete']);
    Route::patch('/{id}', [WorkflowTemplateController::class, 'onOff']);
});

// 内网服务
Route::prefix('internal')->middleware([InternalApiAuth::class])->group(function () {

    // 供应链招标
    Route::prefix('supplier_tender')->group(function () {
        Route::post('init', [SupplierTenderController::class, 'init']);
        Route::get('order/{id}', [SupplierTenderController::class, 'order']);
        Route::get('orders', [SupplierTenderController::class, 'orders']);
        Route::post('audit/{id}', [SupplierTenderController::class, 'audit']);
        Route::post('addLog', [SupplierTenderController::class, 'addLog']);
        Route::get('logs/{id}', [SupplierTenderController::class, 'logs']);
    });
});

// v2
Route::prefix('v2')->middleware([FeishuWebAuth::class, UserPermissionAuth::class])->group(function () {

    // 模板
    Route::prefix('template')->group(function () {
        Route::post('/', [WorkflowV2TemplateController::class, 'add']);
        Route::put('/', [WorkflowV2TemplateController::class, 'edit']);
        Route::get('/{id}', [WorkflowV2TemplateController::class, 'detail']);
        Route::get('/', [WorkflowV2TemplateController::class, 'index']);
        Route::delete('/{id}', [WorkflowV2TemplateController::class, 'delete']);
        Route::patch('/{id}', [WorkflowV2TemplateController::class, 'onOff']);
    });

    Route::prefix('order')->group(function () {
        Route::get('list', [\App\Http\Controllers\Workflow\WorkflowV2OrderController::class, 'list']);
        Route::get('detail', [\App\Http\Controllers\Workflow\WorkflowV2OrderController::class, 'detail']);
        Route::post('submitOrder', [\App\Http\Controllers\Workflow\WorkflowV2OrderController::class, 'submitOrder']);//提交审批
        Route::get('closeOrder', [\App\Http\Controllers\Workflow\WorkflowV2OrderController::class, 'closeOrder']);//关闭
    });

});
